package com.shenmazong.servereduuser.service.impl;

import com.shenmazong.servereduuser.entity.TbAdmin;
import com.shenmazong.servereduuser.entity.TbStaff;
import com.shenmazong.servereduuser.entity.TbStudent;
import com.shenmazong.servereduuser.mapper.TbAdminMapper;
import com.shenmazong.servereduuser.mapper.TbStaffMapper;
import com.shenmazong.servereduuser.mapper.TbStudentMapper;
import com.shenmazong.servereduuser.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * @author GuanJiaHe
 * @version 1.0
 * @description TODO
 * @date 2021/9/23 10:24
 */
@Service
public class IndexServiceImpl implements IndexService {
    @Autowired
    private TbAdminMapper adminMapper;

    @Autowired
    private TbStudentMapper studentMapper;

    @Autowired
    private TbStaffMapper staffMapper;

    @Override
    public HashMap<String, Object> selectManager(Long loginId) {
        TbAdmin admin = adminMapper.selectById(loginId);
        HashMap<String,Object> map=new HashMap<>();
        ArrayList<String> permissions = new ArrayList<>();
        //后续从数据库中查询
        permissions.add("admin");
        map.put("permissions", permissions);
        map.put("username", admin.getAdminName());
        map.put("userRealName", admin.getRealName());
        map.put("avatar", "https://i.gtimg.cn/club/item/face/img/8/15918_100.gif");
        return map;
    }

    @Override
    public HashMap<String, Object> selectStudent(Long loginId) {
        TbStudent tbStudent = studentMapper.selectById(loginId);
        HashMap<String,Object> map=new HashMap<>();
        ArrayList<String> permissions = new ArrayList<>();
        //后续从数据库中查询
        permissions.add("admin");
        map.put("permissions", permissions);
        map.put("username", tbStudent.getStuName());
        map.put("userRealName", tbStudent.getRealName());
        map.put("avatar", "https://i.gtimg.cn/club/item/face/img/8/15918_100.gif");
        return map;
    }

    @Override
    public HashMap<String, Object> selectStaff(Long loginId) {
        TbStaff tbStaff = staffMapper.selectById(loginId);
        HashMap<String,Object> map=new HashMap<>();
        ArrayList<String> permissions = new ArrayList<>();
        //后续从数据库中查询
        permissions.add("admin");
        map.put("permissions", permissions);
        map.put("username", tbStaff.getStaffName());
        map.put("userRealName", tbStaff.getRealName());
        map.put("avatar", "https://i.gtimg.cn/club/item/face/img/8/15918_100.gif");
        return map;
    }
}
